package soundsystem;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.ApplicationContext;


/**
 * Created by jack on 18/5/28.
 */

public class Main {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        ApplicationContext context = new AnnotationConfigApplicationContext(CDPlayerConfig.class);
        long end = System.currentTimeMillis();
        System.out.println("Context 启动花费时间: " + (end - start) + "ms");
        Object a = context.getBean("compactDisc");
        (((CompactDisc) a)).play();
        Object b = context.getBean("compactDisc");
        (((CompactDisc) b)).play();
        Object c = context.getBean("compactDisc");
        ((CompactDisc) c).play();
        //每次获得的都是同样的实例,不知道这样获取的实例是否是线程安全的//
        System.out.println(a == b);
        System.out.println(a == c);
        MP4 mp4 = (MP4) context.getBean("mp4");
        System.out.println(mp4);
    }
}
